import type { HttpRequestHeader } from 'ant-design-vue/es/upload/interface'

export const STORAGE_AUTHORIZE_KEY = 'Authorization'

export const useAuthorization = createGlobalState(() => useStorage<null | string>(STORAGE_AUTHORIZE_KEY, null))

export function useHeaders(): HttpRequestHeader {
  const token = useAuthorization()
  return {
    [STORAGE_AUTHORIZE_KEY]: unref(token)!,
  }
}
